#include "mainwindow.h"

#include <QApplication>
#include <QFileSystemModel>
#include <QListView>
#include <QSplitter>
#include <QTreeView>
#include <QTableView>
#include <QPixmap>
#include <QStandardItemModel>


int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QStandardItemModel model;
    auto * parentItem = model.invisibleRootItem();
    QStandardItem * item0 = new QStandardItem();
    QPixmap pixmap0(30,30);
    pixmap0.fill(Qt::red);
    item0->setIcon(pixmap0);
    item0->setText("item0");
    item0->setToolTip("indexA");
    parentItem->appendRow(item0);

    parentItem = item0;

    QStandardItem * item1 = new QStandardItem();
    QPixmap pixmap1(30,30);
    pixmap1.fill(Qt::blue);
    item1->setIcon(pixmap1);
    item1->setText("item1");
    item1->setToolTip("indexB");
    parentItem->appendRow(item1);


    QStandardItem * item2 = new QStandardItem();
    item2->setData("item2",Qt::EditRole);
    QPixmap pixmap2(50,50);
    pixmap2.fill(Qt::green);
    item2->setData(QIcon(pixmap2), Qt::DecorationRole);
    item2->setData("indexC",Qt::ToolTipRole);
    parentItem->appendRow(item2);

    QTreeView view;
    view.setModel(&model);
    view.show();

    QModelIndex indexA = model.index(0,0,QModelIndex());
    qDebug() << "index A text is " << model.data(indexA,Qt::EditRole);
    qDebug() << "index A Icon is " << model.data(indexA,Qt::DecorationRole);
    qDebug() << "index A tool tip is " << model.data(indexA,Qt::ToolTipRole);

    QModelIndex indexC = model.index(1,0,indexA);
    qDebug() << "index C text is " << model.data(indexC,Qt::EditRole);
    qDebug() << "index C Icon is " << model.data(indexC,Qt::DecorationRole);
    qDebug() << "index C tool tip is " << model.data(indexC,Qt::ToolTipRole);


    // QSplitter *splitter = new QSplitter;
    // QFileSystemModel * model2 = new QFileSystemModel;
    // model2->setRootPath(QDir::currentPath());

    // QTreeView * tree = new QTreeView(splitter);
    // tree->setModel(model2);
    // tree->setRootIndex(model2->index(QDir::currentPath()));

    // QListView * list = new QListView(splitter);
    // list->setModel(model2);
    // list->setRootIndex(model2->index(QDir::currentPath()));


    // splitter->resize(1000,800);
    // splitter->show();

    return a.exec();
}
